//package com.fingard.dsp.bank.directbank.ccb04;
//
//import com.fingard.constant.Format;
//import com.fingard.dsp.bank.directbank.bankInterface.IElecBillTrans;
//import com.fingard.dsp.bank.directbank.ccb04.util.RSAHelper;
//import com.fingard.dsp.bank.reqrespobj.elecbilltrans.*;
//import com.fingard.dsp.bank.reqrespobj.elecbilltrans.detail.*;
//import com.fingard.io.FileHelper;
//import com.fingard.text.StringHelper;
//import com.fingard.util.DateHelper;
//import com.fingard.xml.XElement;
//import com.fingard.xml.XmlTextReader;
//import com.fingard.xml.XmlTextWriter;
//
//import java.io.File;
//import java.util.Calendar;
//import java.util.Date;
//
///**
// * @author Parker on 2019-12-12.
// * @version 1.0
// */
//public class CCB04ElecBillTrans extends CCB04Base implements IElecBillTrans {
//    //通用签收
//    @Override
//    public RetAtsB003BillRespSubmit D_B003_BillResp_Submit(ReqB003BillRespSubmit query) throws Exception {
//        RetAtsB003BillRespSubmit retAts = new RetAtsB003BillRespSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB003BillRespSubmitDetail detail = new RetAtsB003BillRespSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS214";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            String bkType;
//                            switch (Integer.valueOf(query.detail.respType)) {
//                                //1-承兑应答 2-收票应答 3-背书转让应答 4-回购式贴现赎回应答 5-质押解除应答 6-提示付款应答 7-保证应答 8-同意清偿应
//                                case 1:
//                                    bkType = "0001";
//                                    break;
//                                case 2:
//                                    bkType = "0002";
//                                    break;
//                                case 3:
//                                    bkType = "0003";
//                                    break;
//                                case 4:
//                                    bkType = "0005";
//                                    break;
//                                case 5:
//                                    bkType = "0013";
//                                    break;
//                                case 6:
//                                    if ("2".equals(query.detail.proPayType)) {
//                                        bkType = "0015";
//                                    } else {
//                                        bkType = "0014";
//                                    }
//                                    break;
//                                case 7:
//                                    throw new Exception("银行暂不支持保证类型的签收");
//                                case 8:
//                                    bkType = "0016";
//                                    break;
//                                case 9:
//                                    bkType = "0012";
//                                    break;
//                                default:
//                                    throw new Exception("未知的签收类型：" + query.detail.respType);
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", bkType);//回复类型
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            String bkRole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkRole);//回复人类别
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票回复人组织机构代码 TODO
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//原电票回复人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.respBnkCode);//原电票回复人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2", "");//原电票回复人承接行行号
//                            if ("1".equals(query.detail.respType)) {
//                                xmlWriterWithoutCDATA.writeElementString("BkLevel1", query.detail.accpCredit);//承兑人信用等级
//                                xmlWriterWithoutCDATA.writeElementString("BkPrtFileName", query.detail.accpGrade);//承兑人评级机构
//                                xmlWriterWithoutCDATA.writeElementString("Bk8Date1", DateHelper.convertD10toD8(query.detail.accpGradeDue));//承兑人评级到期日
//                            } else {
//                                xmlWriterWithoutCDATA.writeElementString("BkLevel1", "");//承兑人信用等级
//                                xmlWriterWithoutCDATA.writeElementString("BkPrtFileName", "");//承兑人评级机构
//                                xmlWriterWithoutCDATA.writeElementString("Bk8Date1", "");//承兑人评级到期日
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("BkAddr", query.detail.guarAddr);//原电票保证人地址
//                            if ("1".equals(query.detail.respType)) {
//                                xmlWriterWithoutCDATA.writeElementString("BkListNo4", query.detail.protocolNo);//原电票协议编号
//                            } else {
//                                xmlWriterWithoutCDATA.writeElementString("BkListNo4", "");//原电票协议编号
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("BkType2", "1".equals(query.detail.respFlag) ? "SU00" : "SU01");//回复标记
//                            if ("6".equals(query.detail.respType) && "2".equals(query.detail.respFlag)) {
//                                if (StringHelper.isNullOrEmpty(query.detail.unPayCode)) {
//                                    throw new Exception("提示付款拒签时，拒付理由不能为空!");
//                                }
//                                if ("99".equals(query.detail.unPayCode)) {
//                                    xmlWriterWithoutCDATA.writeElementString("BkType3", "DC09");
//                                } else {
//                                    xmlWriterWithoutCDATA.writeElementString("BkType3", "DC0" + (Integer.valueOf(query.detail.unPayCode) - 1));
//                                }
//                            } else {
//                                xmlWriterWithoutCDATA.writeElementString("BkType3", "");
//                            }
//                            String[] ecdsInfo = query.detail.busiNo.split("_");
//                            if (StringHelper.hasAnyChar(query.detail.busiNo)) {
//                                //                20 BkOldPlatDate 原ECDS平台日期 Char(8) F 　
//                                xmlWriterWithoutCDATA.writeElementString("BkOldPlatDate", ecdsInfo[0]);
////                21 BkOldSeq 原ECDS平台流水 Int F 　
//                                xmlWriterWithoutCDATA.writeElementString("BkOldSeq", ecdsInfo[1]);
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = "原ECDS平台流水异常。请确认应答查询是否返回BkOldPlatDate和BkOldSeq的值";
//                                WriteBankLogLn("原ECDS平台流水异常。请确认应答查询是否返回BkOldPlatDate和BkOldSeq的值");
//                                retAts.writeDetail(detail);
//                                retAts.writeEnd();
//                                return retAts;
//                            }
//                            //拒付备注
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.unPayMemo);
////                          23 BkDetail2 回复人备注 varChar(512) T 　
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail2", query.detail.memo + "-" + query.detail.reqSeqID);
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkType1", bkType);//回复类型
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkRole", bkRole);//回复人类别
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票回复人组织机构代码 TODO
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//原电票回复人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.respBnkCode);//原电票回复人开户行行号
//                            xmlWriter.writeElementCDATA("BkBrchNo2", "");//原电票回复人承接行行号
//                            if ("1".equals(query.detail.respType)) {
//                                xmlWriter.writeElementCDATA("BkLevel1", query.detail.accpCredit);//承兑人信用等级
//                                xmlWriter.writeElementCDATA("BkPrtFileName", query.detail.accpGrade);//承兑人评级机构
//                                xmlWriter.writeElementCDATA("Bk8Date1", DateHelper.convertD10toD8(query.detail.accpGradeDue));//承兑人评级到期日
//                            } else {
//                                xmlWriter.writeElementCDATA("BkLevel1", "");//承兑人信用等级
//                                xmlWriter.writeElementCDATA("BkPrtFileName", "");//承兑人评级机构
//                                xmlWriter.writeElementCDATA("Bk8Date1", "");//承兑人评级到期日
//                            }
//                            xmlWriter.writeElementCDATA("BkAddr", query.detail.guarAddr);//原电票保证人地址
//                            if ("1".equals(query.detail.respType)) {
//                                xmlWriter.writeElementCDATA("BkListNo4", query.detail.protocolNo);//原电票协议编号
//                            } else {
//                                xmlWriter.writeElementCDATA("BkListNo4", "");//原电票协议编号
//                            }
//                            xmlWriter.writeElementCDATA("BkType2", "1".equals(query.detail.respFlag) ? "SU00" : "SU01");//回复标记
//                            if ("6".equals(query.detail.respType) && "2".equals(query.detail.respFlag)) {
//                                if (StringHelper.isNullOrEmpty(query.detail.unPayCode)) {
//                                    throw new Exception("提示付款拒签时，拒付理由不能为空!");
//                                }
//                                if ("99".equals(query.detail.unPayCode)) {
//                                    xmlWriter.writeElementCDATA("BkType3", "DC09");
//                                } else {
//                                    xmlWriter.writeElementCDATA("BkType3", "DC0" + (Integer.valueOf(query.detail.unPayCode) - 1));
//                                }
//                            } else {
//                                xmlWriter.writeElementCDATA("BkType3", "");
//                            }
//                            if (StringHelper.hasAnyChar(query.detail.busiNo)) {
//                                //                20 BkOldPlatDate 原ECDS平台日期 Char(8) F 　
//                                xmlWriter.writeElementCDATA("BkOldPlatDate", ecdsInfo[0]);
////                21 BkOldSeq 原ECDS平台流水 Int F 　
//                                xmlWriter.writeElementCDATA("BkOldSeq", ecdsInfo[1]);
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = "原ECDS平台流水异常。请确认应答查询是否返回BkOldPlatDate和BkOldSeq的值";
//                                WriteBankLogLn("原ECDS平台流水异常。请确认应答查询是否返回BkOldPlatDate和BkOldSeq的值");
//                                retAts.writeDetail(detail);
//                                retAts.writeEnd();
//                                return retAts;
//                            }
//                            //拒付备注
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.unPayMemo);
////                          23 BkDetail2 回复人备注 varChar(512) T 　
//                            xmlWriter.writeElementCDATA("BkDetail2", query.detail.memo + "-" + query.detail.reqSeqID);
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //出票
//    @Override
//    public RetAtsB101BillApplySubmit D_B101_BillResp_Submit(ReqB101BillApplySubmit query) throws Exception {
//        RetAtsB101BillApplySubmit retAts = new RetAtsB101BillApplySubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        RetAtsB101BillApplySubmitDetail detail;
//        while (query.readRecord()) {
//            if ("1".equals(query.detail.billType)) {
//                detail = B101_Submit_AC01(query);
//            } else {
//                detail = B101_Submit_ACO2(query);
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeAfter();
//        return retAts;
//    }
//
//    //确认银承出票申请 按协议出票 ATS暂不支持
//    public RetAtsB101BillApplySubmitDetail B101_Submit_AC01(ReqB101BillApplySubmit query) throws Exception {
//        RetAtsB101BillApplySubmitDetail detail = new RetAtsB101BillApplySubmitDetail();
//        try {
//            getBnkToken();
//            if (StringHelper.hasAnyChar(bankFront.token)) {
//                if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                    if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                        txCode = "P1ECDS202";
//                        reqSeqID = query.reqHeader.transSeqID;
//                        XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                        //写入报文头部信息
//                        writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                        xmlWriterWithoutCDATA.writeStartElement("request");
//                        writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.detail.drawBnkCode, 0);
//                        xmlWriterWithoutCDATA.writeElementString("BkInstNo", query.detail.drawCode);//原电票组织机构代码
//                        xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.contractNo);//原电票协议编号
//                        xmlWriterWithoutCDATA.writeElementString("BkLevel1", query.detail.creditLv);//出票人信用等级
//                        xmlWriterWithoutCDATA.writeElementString("Bk60Name2", query.detail.gradeAgent);//出票人评级机构
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date3", query.detail.gradeDueDate);//出票人评级到期日
//                        XmlTextReader xmlTextReader = queryBillByP1ECDS252(query.detail.contractNo, query.detail.drawCode, query.reqHeader.srcBankCode);
//                        String totalnum = xmlTextReader.getFirstText("/Transaction/Transaction_Body/response/BkNum1");
//                        xmlWriterWithoutCDATA.writeElementString("BkNum1", totalnum);//循环次数
//                        while (xmlTextReader.read("/Transaction/Transaction_Body/response/Bkxycpxxcx_GRP")) {
//                            xmlWriterWithoutCDATA.writeStartElement("Bkqryccpsq_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo2", xmlTextReader.readedXElement.getSingleText("BkListNo1"));//CLPM票据编号
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo3", xmlTextReader.readedXElement.getSingleText("BkListNo3"));//交易合同编号
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo4", xmlTextReader.readedXElement.getSingleText("BkListNo4"));//发票号码
//                            xmlWriterWithoutCDATA.writeElementString("BkEcdBatchNo", "");//批次号
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", xmlTextReader.readedXElement.getSingleText("Bk8Date1"));//出票日
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date2", xmlTextReader.readedXElement.getSingleText("Bk8Date2"));//票据到期日
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail2", xmlTextReader.readedXElement.getSingleText("BkDetail1"));//原电票备注
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "EM00");//不得转让标记EM00可再转让EM01不得转让  待确认
//                            xmlWriterWithoutCDATA.writeEndElement();
//                        }
//                        xmlWriterWithoutCDATA.writeEndDocument();
//                        int n = xmlWriterWithoutCDATA.toXmlString().length();
//                        xmlLength = decimalFormat.format(n);
//
//                        XmlTextWriter xmlWriter = new XmlTextWriter();
//                        writeCommonHeader(xmlWriter);
//                        xmlWriter.writeStartElement("request");
//                        writeElecBillComEntity(xmlWriter, query.detail.reqSeqID, query.detail.drawBnkCode, 0);
//                        xmlWriter.writeElementCDATA("BkInstNo", query.detail.drawCode);//原电票组织机构代码
//                        xmlWriter.writeElementCDATA("BkListNo1", query.detail.contractNo);//原电票协议编号
//                        xmlWriter.writeElementCDATA("BkLevel1", query.detail.creditLv);//出票人信用等级
//                        xmlWriter.writeElementCDATA("Bk60Name2", query.detail.gradeAgent);//出票人评级机构
//                        xmlWriter.writeElementCDATA("Bk8Date3", query.detail.gradeDueDate);//出票人评级到期日
//                        xmlWriter.writeElementCDATA("BkNum1", totalnum);//循环次数
//                        while (xmlTextReader.read("/Transaction/Transaction_Body/response/Bkxycpxxcx_GRP")) {
//                            xmlWriter.writeStartElement("Bkqryccpsq_GRP");
//                            xmlWriter.writeElementCDATA("BkListNo2", xmlTextReader.readedXElement.getSingleText("BkListNo1"));//CLPM票据编号
//                            xmlWriter.writeElementCDATA("BkListNo3", xmlTextReader.readedXElement.getSingleText("BkListNo3"));//交易合同编号
//                            xmlWriter.writeElementCDATA("BkListNo4", xmlTextReader.readedXElement.getSingleText("BkListNo4"));//发票号码
//                            xmlWriter.writeElementCDATA("BkEcdBatchNo", "");//批次号
//                            xmlWriter.writeElementCDATA("Bk8Date1", xmlTextReader.readedXElement.getSingleText("Bk8Date1"));//出票日
//                            xmlWriter.writeElementCDATA("Bk8Date2", xmlTextReader.readedXElement.getSingleText("Bk8Date2"));//票据到期日
//                            xmlWriter.writeElementCDATA("BkDetail2", xmlTextReader.readedXElement.getSingleText("BkDetail1"));//原电票备注
//                            xmlWriter.writeElementCDATA("BkType1", "EM00");//不得转让标记EM00可再转让EM01不得转让 TODO 待确认
//                            xmlWriter.writeEndElement();
//                        }
//                        xmlWriter.writeEndDocument();
//
//                        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                        if (tmpStrRet[0].length() == 0) {
//                            StringBuilder msg = new StringBuilder();
//                            XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                            if (tmpBkReader != null) {
//                                String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                detail.respCode = "0";
//                                detail.reqSeqID = query.detail.reqSeqID;
//                                if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                    String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                    detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                    detail.transState = strResultCode;
//                                } else {
//                                    detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                    detail.transState = xln_resp_code;
//                                }
//                                detail.payInfoCode = detail.transState;
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = msg.toString();
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = tmpStrRet[1];
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "签到失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行pub密钥失败";
//                }
//            } else {
//                detail.respCode = "-1";
//                detail.respInfo = "下载银行3des密钥失败";
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            WriteBankLogLn("出票人" + query.detail.drawName + "出票异常");
//        }
//        return detail;
//    }
//
//    //确认商承出票申请
//    public RetAtsB101BillApplySubmitDetail B101_Submit_ACO2(ReqB101BillApplySubmit query) throws Exception {
//        RetAtsB101BillApplySubmitDetail detail = new RetAtsB101BillApplySubmitDetail();
//        try {
//            getBnkToken();
//            if (StringHelper.hasAnyChar(bankFront.token)) {
//                if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                    if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                        txCode = "P1ECDS203";
//                        reqSeqID = query.reqHeader.transSeqID;
//                        XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                        //写入报文头部信息
//                        writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                        xmlWriterWithoutCDATA.writeStartElement("request");
//                        writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.detail.drawBnkCode, 0);
//                        xmlWriterWithoutCDATA.writeElementString("BkType1", "AC02");//只能填写 AC02商承
//                        xmlWriterWithoutCDATA.writeElementString("BkAmt1", query.detail.billAmt);//原电票票据金额
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date1", DateHelper.convertDateTimetoD8(query.detail.issDate));//原电票出票日期
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date2", DateHelper.convertDateTimetoD8(query.detail.dueDate));//原电票到期日
//                        xmlWriterWithoutCDATA.writeElementString("BkType2", "1".equals(query.detail.transFlag) ? "EM00" : "EM01");//不得转让标记EM00可再转让EM01不得转让
//                        String bkType = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.drawAct);
//                        xmlWriterWithoutCDATA.writeElementString("BkType3", bkType);//只能为RC01企业
//                        xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.drawName);//原电票出票人名称
//                        xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.drawAct));//原电票出票人组织机构代码
//                        xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.drawAct);//原电票出票人账号
//                        xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.drawBnkCode);//原电票出票人开户行行号
//                        xmlWriterWithoutCDATA.writeElementString("BkLevel1", query.detail.creditLv);//出票人信用等级
//                        xmlWriterWithoutCDATA.writeElementString("Bk60Name2", query.detail.gradeAgent);//出票人评级机构
//                        xmlWriterWithoutCDATA.writeElementString("Bk8Date3", DateHelper.convertDateTimetoD8(query.detail.gradeDueDate));//出票人评级到期日
//                        xmlWriterWithoutCDATA.writeElementString("BkDetail1", "");//出票人承诺
//                        xmlWriterWithoutCDATA.writeElementString("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//出票人备注
//                        xmlWriterWithoutCDATA.writeElementString("Bk60Name3", query.detail.accpName);//原电票承兑人名称
//                        xmlWriterWithoutCDATA.writeElementString("BkAcctNo3", query.detail.accpAct);//原电票承兑人账号
//                        xmlWriterWithoutCDATA.writeElementString("BkBrchNo3", query.detail.accpBnkCode);//原电票承兑人开户行行号
//                        xmlWriterWithoutCDATA.writeElementString("Bk60Name4", query.detail.payeeName);//原电票收款人名称
//                        xmlWriterWithoutCDATA.writeElementString("BkAcctNo4", query.detail.payeeAct);//原电票收款人账号
//                        xmlWriterWithoutCDATA.writeElementString("BkBrchNo4", query.detail.payeeBnkCode);//原电票收款人开户行行号
//                        xmlWriterWithoutCDATA.writeElementString("BkDetail3", query.detail.reqSeqID);//备注2
//                        xmlWriterWithoutCDATA.writeElementString("BkType4", "");//出票流程标记
//                        xmlWriterWithoutCDATA.writeEndDocument();
//                        int n = xmlWriterWithoutCDATA.toXmlString().length();
//                        xmlLength = decimalFormat.format(n);
//
//                        XmlTextWriter xmlWriter = new XmlTextWriter();
//                        writeCommonHeader(xmlWriter);
//                        xmlWriter.writeStartElement("request");
//                        writeElecBillComEntity(xmlWriter, query.detail.reqSeqID, query.detail.drawBnkCode, 0);
//                        xmlWriter.writeElementCDATA("BkType1", "AC02");//只能填写 AC02商承
//                        xmlWriter.writeElementCDATA("BkAmt1", query.detail.billAmt);//原电票票据金额
//                        xmlWriter.writeElementCDATA("Bk8Date1", DateHelper.convertDateTimetoD8(query.detail.issDate));//原电票出票日期
//                        xmlWriter.writeElementCDATA("Bk8Date2", DateHelper.convertDateTimetoD8(query.detail.dueDate));//原电票到期日
//                        xmlWriter.writeElementCDATA("BkType2", "1".equals(query.detail.transFlag) ? "EM00" : "EM01");//不得转让标记EM00可再转让EM01不得转让
//                        xmlWriter.writeElementCDATA("BkType3", bkType);//只能为RC01企业
//                        xmlWriter.writeElementCDATA("Bk60Name1", query.detail.drawName);//原电票出票人名称
//                        xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.drawAct));//原电票出票人组织机构代码
//                        xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.drawAct);//原电票出票人账号
//                        xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.drawBnkCode);//原电票出票人开户行行号
//                        xmlWriter.writeElementCDATA("BkLevel1", query.detail.creditLv);//出票人信用等级
//                        xmlWriter.writeElementCDATA("Bk60Name2", query.detail.gradeAgent);//出票人评级机构
//                        xmlWriter.writeElementCDATA("Bk8Date3", DateHelper.convertDateTimetoD8(query.detail.gradeDueDate));//出票人评级到期日
//                        xmlWriter.writeElementCDATA("BkDetail1", "");//出票人承诺
//                        xmlWriter.writeElementCDATA("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//出票人备注
//                        xmlWriter.writeElementCDATA("Bk60Name3", query.detail.accpName);//原电票承兑人名称
//                        xmlWriter.writeElementCDATA("BkAcctNo3", query.detail.accpAct);//原电票承兑人账号
//                        xmlWriter.writeElementCDATA("BkBrchNo3", query.detail.accpBnkCode);//原电票承兑人开户行行号
//                        xmlWriter.writeElementCDATA("Bk60Name4", query.detail.payeeName);//原电票收款人名称
//                        xmlWriter.writeElementCDATA("BkAcctNo4", query.detail.payeeAct);//原电票收款人账号
//                        xmlWriter.writeElementCDATA("BkBrchNo4", query.detail.payeeBnkCode);//原电票收款人开户行行号
//                        xmlWriter.writeElementCDATA("BkDetail3", query.detail.reqSeqID);//备注2
//                        xmlWriter.writeElementCDATA("BkType4", getBankConfig().getValueAsString("autoPpocedure"));//出票流程标记
//                        xmlWriter.writeEndDocument();
//
//                        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                        if (tmpStrRet[0].length() == 0) {
//                            StringBuilder msg = new StringBuilder();
//                            XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                            if (tmpBkReader != null) {
//                                String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                detail.respCode = "0";
//                                detail.reqSeqID = query.detail.reqSeqID;
//                                if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                    String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                    detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                    detail.transState = strResultCode;
//                                } else {
//                                    detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                    detail.transState = xln_resp_code;
//                                }
//                                detail.payInfoCode = detail.transState;
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = msg.toString();
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = tmpStrRet[1];
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "签到失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行pub密钥失败";
//                }
//            } else {
//                detail.respCode = "-1";
//                detail.respInfo = "下载银行3des密钥失败";
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            WriteBankLogLn("出票人" + query.detail.drawName + "出票异常");
//        }
//        return detail;
//    }
//
//    //商承提示承兑申请
//    @Override
//    public RetAtsB102BillAccpSubmit D_B102_BillResp_Submit(ReqB102BillAccpSubmit query) throws Exception {
//        RetAtsB102BillAccpSubmit retAts = new RetAtsB102BillAccpSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB102BillAccpSubmitDetail detail = new RetAtsB102BillAccpSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS219";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.detail.drawBnkCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "CC00");//到期无条件支付委托 只能填写CC00：含委托/承诺兑付
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo2", query.detail.contractNo);//交易合同编号
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo3", query.detail.invoiceNo);//发票号码
//                            xmlWriterWithoutCDATA.writeElementString("BkEcdBatchNo", query.detail.reqSeqID);//批次号
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出票人备注
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//RC00银行 RC01企业 RC02央行 RC03被代理行 RC04财务公司
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.drawName);//原电票出票人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//原电票出票人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.drawBnkCode);//原电票出票人开户行行号
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.detail.reqSeqID, query.detail.drawBnkCode, 0);
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkType1", "CC00");//到期无条件支付委托 只能填写CC00：含委托/承诺兑付
//                            xmlWriter.writeElementCDATA("BkListNo2", query.detail.contractNo);//交易合同编号
//                            xmlWriter.writeElementCDATA("BkListNo3", query.detail.invoiceNo);//发票号码
//                            xmlWriter.writeElementCDATA("BkEcdBatchNo", query.detail.reqSeqID);//批次号
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出票人备注
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//RC00银行 RC01企业 RC02央行 RC03被代理行 RC04财务公司
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出票人组织机构代码
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.drawName);//原电票出票人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//原电票出票人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.drawBnkCode);//原电票出票人开户行行号
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//                WriteBankLogLn("提示承兑异常");
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeAfter();
//        return retAts;
//    }
//
//    //撤票
//    @Override
//    public RetAtsB103BillRetSubmit D_B103_BillResp_Submit(ReqB103BillRetSubmit query) throws Exception {
//        RetAtsB103BillRetSubmit retAts = new RetAtsB103BillRetSubmit(query.reqHeader);
//        RetAtsB103BillRetSubmitDetail detail = new RetAtsB103BillRetSubmitDetail();
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS205";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkTotNum", String.valueOf(1));//循环次数
//                            xmlWriterWithoutCDATA.writeStartElement("Bkcpsq_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票组织机构代码
//                            String priKey = FileHelper.readFileText(strtmpFile + bankFront.org + "_prikey.txt", getCharset());
//                            xmlWriterWithoutCDATA.writeElementString("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkTotNum", String.valueOf(1));//循环次数
//                            xmlWriter.writeStartElement("Bkcpsq_GRP");
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票组织机构代码
//                            xmlWriter.writeElementCDATA("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//                WriteBankLogLn("撤票异常：" + ex.getMessage());
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //收票
//    @Override
//    public RetAtsB104BillReceSubmit D_B104_BillResp_Submit(ReqB104BillReceSubmit query) throws Exception {
//        RetAtsB104BillReceSubmit retAts = new RetAtsB104BillReceSubmit(query.reqHeader);
//        RetAtsB104BillReceSubmitDetail detail = new RetAtsB104BillReceSubmitDetail();
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS204";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementCDATA("BkTotNum", String.valueOf(1));//循环次数
//                            xmlWriterWithoutCDATA.writeStartElement("Bktsspsq_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出票人备注
//                            String priKey = FileHelper.readFileText(strtmpFile + bankFront.org + "_prikey.txt", getCharset());
//                            xmlWriterWithoutCDATA.writeElementString("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo4", query.detail.reqSeqID);//订单号码
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkTotNum", String.valueOf(1));//循环次数
//                            xmlWriter.writeStartElement("Bktsspsq_GRP");
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票组织机构代码
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出票人备注
//                            xmlWriter.writeElementCDATA("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriter.writeElementCDATA("BkListNo4", query.detail.reqSeqID);//订单号码
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//                WriteBankLogLn("收票异常：" + ex.getMessage());
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //背书
//    @Override
//    public RetAtsB105BillEndoSubmit D_B105_BillResp_Submit(ReqB105BillEndoSubmit query) throws Exception {
//        RetAtsB105BillEndoSubmit retAts = new RetAtsB105BillEndoSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB105BillEndoSubmitDetail detail = new RetAtsB105BillEndoSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS206";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "1".equals(query.detail.transFlag) ? "EM00" : "EM01");//背书不得转让标记
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//背书人备注
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//背书人类别
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.endoName);//原电票背书人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//背书人组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//背书人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.endoBnkCode);//原电票背书人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name3", query.detail.receName);//原电票被背书人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo3", query.detail.receAct);//原电票被背书人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo3", query.detail.receBnkCode);//被背书人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//备注2
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo4", query.detail.reqSeqID);//订单号码
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkType1", "1".equals(query.detail.transFlag) ? "EM00" : "EM01");//背书不得转让标记
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//背书人备注
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//背书人类别
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.endoName);//原电票背书人名称
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//背书人组织机构代码 TODO
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//背书人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.endoBnkCode);//原电票背书人开户行行号
//                            xmlWriter.writeElementCDATA("Bk60Name3", query.detail.receName);//原电票被背书人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo3", query.detail.receAct);//原电票被背书人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo3", query.detail.receBnkCode);//被背书人开户行行号
//                            xmlWriter.writeElementCDATA("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//备注2
//                            xmlWriter.writeElementCDATA("BkListNo4", query.detail.reqSeqID);//订单号码
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//                WriteBankLogLn("背书异常：" + ex.getMessage());
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //贴现
//    @Override
//    public RetAtsB106BillDiscSubmit D_B106_BillResp_Submit(ReqB106BillDiscSubmit query) throws Exception {
//        RetAtsB106BillDiscSubmit retAts = new RetAtsB106BillDiscSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        RetAtsB106BillDiscSubmitDetail detail = new RetAtsB106BillDiscSubmitDetail();
//        while (query.readRecord()) {
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS208";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkNum1", String.valueOf(1));//贴现总笔数
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt9", query.detail.discAmt);//贴现总金额
//                            String priKey = FileHelper.readFileText(strtmpFile + bankFront.org + "_prikey.txt", getCharset());
//                            xmlWriterWithoutCDATA.writeElementString("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriterWithoutCDATA.writeStartElement("BkAplInfo_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", "1".equals(query.detail.discType) ? "RM00" : "RM01");//贴现种类 RM00买断式 RM01回购式
//                            xmlWriterWithoutCDATA.writeElementString("BkRate1", query.detail.discRate);//贴现利率
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt2", query.detail.discAmt);//原电票贴现实付金额
//                            if ("2".equals(query.detail.discType)) {
//                                xmlWriterWithoutCDATA.writeElementString("BkType2", "EM00");//贴现不得转让标记 EM00可转让
//                            } else {
//                                xmlWriterWithoutCDATA.writeElementString("BkType2", "1".equals(query.detail.transFlag) ? "EM00" : "EM01");//贴现不得转让标记
//                            }
//                            Calendar calendar = Calendar.getInstance();
//                            calendar.setTime(new Date());
//                            if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
//                                calendar.add(2, Calendar.DAY_OF_MONTH);
//                            } else if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
//                                calendar.add(1, Calendar.DAY_OF_MONTH);
//                            }
//                            int testEnvDiffDay = getBankConfig().getValueAsInt("testEnvDiffDay", 0);
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", Format.Date8Format.format(DateHelper.addDays(calendar.getTime(), testEnvDiffDay)));//贴现预约日期
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date2", DateHelper.convertDateTimetoD8(query.detail.repOpenDate));//贴现赎回开放日
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date3", DateHelper.convertDateTimetoD8(query.detail.repDueDate));//贴现赎回截止日
//                            xmlWriterWithoutCDATA.writeElementString("BkRate2", query.detail.repRate);//原电票贴现赎回利率
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt3", query.detail.repAmt);//原电票贴现赎回金额
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo2", query.detail.contractNo);//贴现交易合同编号
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo3 ", query.detail.invoiceNo);//贴现发票号码
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//贴出人备注
//                            xmlWriterWithoutCDATA.writeElementString("BkEcdBatchNo ", query.detail.reqSeqID);//批次号
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo4", query.detail.actedAct);//入账帐号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo4", query.detail.actedBnkCode);//入帐开户行
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//贴现申请人类别
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.discName);//贴现申请人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//贴现申请人组织机构代码 TODO 待确认
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//贴现申请人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.discBnkCode);//贴现申请人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name3", query.detail.receBnkName);//贴入人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo3", query.detail.receAct);//贴入人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo3", query.detail.receBnkCode);//贴入人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkFlag3", query.detail.payInterestType);//原电票付息方式
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name4", query.detail.payInterestName);//原电票付息人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo5", query.detail.payInterestAct);//原电票付息人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkRate", query.detail.payInterestAct);//付息比例
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//备注2
//                            xmlWriterWithoutCDATA.writeElementString("BkType3", "1".equals(query.detail.payType) ? "SM00" : "SM01");//清算标记 SM00-线上清算
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkNum1", String.valueOf(1));//贴现总笔数
//                            xmlWriter.writeElementCDATA("BkAmt9", query.detail.discAmt);//贴现总金额
//                            xmlWriter.writeElementCDATA("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriter.writeStartElement("BkAplInfo_GRP");
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkType1", "1".equals(query.detail.discType) ? "RM00" : "RM01");//贴现种类 RM00买断式 RM01回购式
//                            xmlWriter.writeElementCDATA("BkRate1", query.detail.discRate);//贴现利率
//                            xmlWriter.writeElementCDATA("BkAmt2", query.detail.discAmt);//原电票贴现实付金额
//                            if ("2".equals(query.detail.discType)) {
//                                xmlWriter.writeElementCDATA("BkType2", "EM00");//贴现不得转让标记 EM00可转让
//                            } else {
//                                xmlWriter.writeElementCDATA("BkType2", "1".equals(query.detail.transFlag) ? "EM00" : "EM01");//贴现不得转让标记
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", Format.Date8Format.format(DateHelper.addDays(calendar.getTime(), testEnvDiffDay)));//贴现预约日期
//                            xmlWriter.writeElementCDATA("Bk8Date2", DateHelper.convertDateTimetoD8(query.detail.repOpenDate));//贴现赎回开放日
//                            xmlWriter.writeElementCDATA("Bk8Date3", DateHelper.convertDateTimetoD8(query.detail.repDueDate));//贴现赎回截止日
//                            xmlWriter.writeElementCDATA("BkRate2", query.detail.repRate);//原电票贴现赎回利率
//                            xmlWriter.writeElementCDATA("BkAmt3", query.detail.repAmt);//原电票贴现赎回金额
//                            xmlWriter.writeElementCDATA("BkListNo2", query.detail.contractNo);//贴现交易合同编号
//                            xmlWriter.writeElementCDATA("BkListNo3 ", query.detail.invoiceNo);//贴现发票号码
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//贴出人备注
//                            xmlWriter.writeElementCDATA("BkEcdBatchNo ", query.detail.reqSeqID);//批次号
//                            xmlWriter.writeElementCDATA("BkAcctNo4", query.detail.actedAct);//入账帐号
//                            xmlWriter.writeElementCDATA("BkBrchNo4", query.detail.actedBnkCode);//入帐开户行
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//贴现申请人类别
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.discName);//贴现申请人名称
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//贴现申请人组织机构代码 TODO 待确认
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//贴现申请人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.discBnkCode);//贴现申请人开户行行号
//                            xmlWriter.writeElementCDATA("Bk60Name3", query.detail.receBnkName);//贴入人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo3", query.detail.receAct);//贴入人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo3", query.detail.receBnkCode);//贴入人开户行行号
//                            xmlWriter.writeElementCDATA("BkFlag3", query.detail.payInterestType);//原电票付息方式
//                            xmlWriter.writeElementCDATA("Bk60Name4", query.detail.payInterestName);//原电票付息人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo5", query.detail.payInterestAct);//原电票付息人账号
//                            xmlWriter.writeElementCDATA("BkRate", query.detail.payInterestAct);//付息比例
//                            xmlWriter.writeElementCDATA("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//备注2
//                            xmlWriter.writeElementCDATA("BkType3", "1".equals(query.detail.payType) ? "SM00" : "SM01");//清算标记 SM00-线上清算
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//                WriteBankLogLn("贴现异常：" + ex.getMessage());
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //质押
//    @Override
//    public RetAtsB107BillPledSubmit D_B107_BillResp_Submit(ReqB107BillPledSubmit query) throws Exception {
//        RetAtsB107BillPledSubmit retAts = new RetAtsB107BillPledSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB107BillPledSubmitDetail detail = new RetAtsB107BillPledSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS209";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出质人备注
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//出质人类别
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出质人组织机构代码  TODO 待确认
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.pledName);//原电票出质人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//原电票出质人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.pledBnkCode);//原电票出质人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name3", query.detail.receName);//原电票质权人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo3", query.detail.receAct);//原电票质权人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo3", query.detail.receBnkCode);//质权人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkEcdBatchNo", query.detail.reqSeqID);//批次号
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出质人备注
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//出质人类别
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出质人组织机构代码  TODO 待确认
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.pledName);//原电票出质人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//原电票出质人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.pledBnkCode);//原电票出质人开户行行号
//                            xmlWriter.writeElementCDATA("Bk60Name3", query.detail.receName);//原电票质权人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo3", query.detail.receAct);//原电票质权人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo3", query.detail.receBnkCode);//质权人开户行行号
//                            xmlWriter.writeElementCDATA("BkEcdBatchNo", query.detail.reqSeqID);//批次号
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//                WriteBankLogLn("质押异常:" + e.getMessage());
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //提示付款
//    @Override
//    public RetAtsB108BillPaySubmit D_B108_BillResp_Submit(ReqB108BillPaySubmit query) throws Exception {
//        RetAtsB108BillPaySubmit retAts = new RetAtsB108BillPaySubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        RetAtsB108BillPaySubmitDetail detail = new RetAtsB108BillPaySubmitDetail();
//        while (query.readRecord()) {
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS211";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkNum1", String.valueOf(1));//提示付款总笔数
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt9", query.detail.billAmt);//提示付款总金额
//                            xmlWriterWithoutCDATA.writeStartElement("Bktsfk_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt2", query.detail.billAmt);//原电票提示付款金额
//                            int testEnvDiffDay = getBankConfig().getValueAsInt("testEnvDiffDay", 0);
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date2", Format.Date8Format.format(DateHelper.addDays(new Date(), testEnvDiffDay)));//提示付款申请日期
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail2", "");//原电票逾期原因说明
//                            xmlWriterWithoutCDATA.writeElementString("BkFlag3", "1".equals(query.detail.payType) ? "0" : "1");//清算方式 0自动清算1：手工清算
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//提示付款人备注
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//提示付款人类别RC00银行RC01企业RC02央行RC03被代理行RC04财务公司
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票提示付款人组织机构代码 TODO 待确认
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.payeeName);//原电票提示付款人名称
//                            String priKey = FileHelper.readFileText(strtmpFile + bankFront.org + "_prikey.txt", getCharset());
//                            xmlWriterWithoutCDATA.writeElementString("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//原电票提示付款人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.payeeBnkCode);//原电票提示付款人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2", "");//原电票提示付款人承接行行号
//
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkNum1", String.valueOf(1));//提示付款总笔数
//                            xmlWriter.writeElementCDATA("BkAmt9", query.detail.billAmt);//提示付款总金额
//                            xmlWriter.writeStartElement("Bktsfk_GRP");
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkAmt2", query.detail.billAmt);//原电票提示付款金额
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date2", Format.Date8Format.format(DateHelper.addDays(new Date(), testEnvDiffDay)));//提示付款申请日期
//                            xmlWriter.writeElementCDATA("BkDetail2", "");//原电票逾期原因说明
//                            xmlWriter.writeElementCDATA("BkFlag3", "1".equals(query.detail.payType) ? "0" : "1");//清算方式 0自动清算1：手工清算
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//提示付款人备注
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//提示付款人类别RC00银行RC01企业RC02央行RC03被代理行RC04财务公司
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票提示付款人组织机构代码 TODO 待确认
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.payeeName);//原电票提示付款人名称
//                            xmlWriter.writeElementCDATA("BkElctSgn1", RSAHelper.sign(query.detail.billNo, priKey, getCharset()));//出票人电子签名
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//原电票提示付款人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.payeeBnkCode);//原电票提示付款人开户行行号
//                            xmlWriter.writeElementCDATA("BkBrchNo2", "");//原电票提示付款人承接行行号
//                            xmlWriter.writeEndElement();
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/BkTsfkRsp_GRP/BkFlag1");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/BkTsfkRsp_GRP/BkDetail1");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//                WriteBankLogLn("贴现异常：" + ex.getMessage());
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //提示保证
//    @Override
//    public RetAtsB109BillGuarSubmit D_B109_BillResp_Submit(ReqB109BillGuarSubmit query) throws Exception {
//        RetAtsB109BillGuarSubmit retAts = new RetAtsB109BillGuarSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB109BillGuarSubmitDetail detail = new RetAtsB109BillGuarSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS207";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            String bkType;
//                            if ("1".equals(query.detail.guarType)) {
//                                bkType = "1";
//                            } else if ("2".equals(query.detail.guarType)) {
//                                bkType = "2";
//                            } else {
//                                bkType = "3";
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", bkType);//保证类别
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo);//被保证人备注
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//原电票被保证人类别
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.guarName);//原电票被保证人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票被保证人组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//原电票被保证人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", "");//原电票被保证人开户行行号 todo
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name2", query.detail.receName);//保证人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo2 ", query.detail.receAct);//原电票保证人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2 ", query.detail.receBnkCode);//保证人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkEcdBatchNo ", "");//批次号
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkType1", bkType);//保证类别
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo);//被保证人备注
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//原电票被保证人类别
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.guarName);//原电票被保证人名称
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票被保证人组织机构代码
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//原电票被保证人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", "");//原电票被保证人开户行行号 todo
//                            xmlWriter.writeElementCDATA("Bk60Name2", query.detail.receName);//保证人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo2 ", query.detail.receAct);//原电票保证人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo2 ", query.detail.receBnkCode);//保证人开户行行号
//                            xmlWriter.writeElementCDATA("BkEcdBatchNo ", "");//批次号
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //追索通知
//    @Override
//    public RetAtsB110BillRecoSubmit D_B110_BillResp_Submit(ReqB110BillRecoSubmit query) throws Exception {
//        RetAtsB110BillRecoSubmit retAts = new RetAtsB110BillRecoSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB110BillRecoSubmitDetail detail = new RetAtsB110BillRecoSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS212";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt1", query.detail.billAmt);//原电票票据金额
//                            String recourseType = query.detail.recourseType;
//                            if ("1".equals(recourseType)) {
//                                xmlWriterWithoutCDATA.writeElementString("BkType1", "RT00");//追索类型
//                            } else {
//                                xmlWriterWithoutCDATA.writeElementString("BkType1", "RT01");
//                            }
//                            int testEnvDiffDay = getBankConfig().getValueAsInt("testEnvDiffDay", 0);
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", Format.Date8Format.format(DateHelper.addDays(new Date(), testEnvDiffDay)));//追索通知日期
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt2", query.detail.recourseAmt);//追索金额
//                            if ("2".equals(recourseType)) {
//                                if ("1".equals(query.detail.recourseCode)) {//追索理由代码
//                                    xmlWriterWithoutCDATA.writeElementString("BkFlag1", "RC00");
//                                } else if ("2".equals(query.detail.recourseCode)) {
//                                    xmlWriterWithoutCDATA.writeElementString("BkFlag1", "RC01");
//                                }
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("BkSumry", query.detail.memo + "_" + query.detail.reqSeqID);//追索通知备注
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//追索人类别
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票被保证人组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.recoName);//原电票追索人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//原电票追索人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.recoBnkCode);//原电票追索人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2", "");//追索人开户行行号2
//                            xmlWriterWithoutCDATA.writeElementString("BkRecNum", "1");//被追索人数
//                            xmlWriterWithoutCDATA.writeStartElement("Bkzssqqq_GRP");
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo1", query.detail.receCode);//被追索人组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name3 ", query.detail.receName);//被追索人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo3 ", query.detail.receAct);//被追索人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo3 ", query.detail.receBnkCode);//被追索人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo4 ", query.detail.receBnkCode);//被追索人承接行行号
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkAmt1", query.detail.billAmt);//原电票票据金额
//                            if ("1".equals(recourseType)) {
//                                xmlWriter.writeElementCDATA("BkType1", "RT00");//追索类型
//                            } else {
//                                xmlWriter.writeElementCDATA("BkType1", "RT01");
//                            }
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", Format.Date8Format.format(DateHelper.addDays(new Date(), testEnvDiffDay)));//追索通知日期
//                            xmlWriter.writeElementCDATA("BkAmt2", query.detail.recourseAmt);//追索金额
//                            if ("2".equals(recourseType)) {
//                                if ("1".equals(query.detail.recourseCode)) {//追索理由代码
//                                    xmlWriter.writeElementCDATA("BkFlag1", "RC00");
//                                } else if ("2".equals(query.detail.recourseCode)) {
//                                    xmlWriter.writeElementCDATA("BkFlag1", "RC01");
//                                }
//                            }
//                            xmlWriter.writeElementCDATA("BkSumry", query.detail.memo + "_" + query.detail.reqSeqID);//追索通知备注
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//追索人类别
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票被保证人组织机构代码
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.recoName);//原电票追索人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//原电票追索人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.recoBnkCode);//原电票追索人开户行行号
//                            xmlWriter.writeElementCDATA("BkBrchNo2", "");//追索人开户行行号2
//                            xmlWriter.writeElementCDATA("BkRecNum", "1");//被追索人数
//                            xmlWriter.writeStartElement("Bkzssqqq_GRP");
//                            xmlWriter.writeElementCDATA("BkInstNo1", query.detail.receCode);//被追索人组织机构代码
//                            xmlWriter.writeElementCDATA("Bk60Name3 ", query.detail.receName);//被追索人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo3 ", query.detail.receAct);//被追索人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo3 ", query.detail.receBnkCode);//被追索人开户行行号
//                            xmlWriter.writeElementCDATA("BkBrchNo4 ", query.detail.receBnkCode);//被追索人承接行行号
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //同意清偿
//    @Override
//    public RetAtsB111BillAgreeSubmit D_B111_BillResp_Submit(ReqB111BillAgreeSubmit query) throws Exception {
//        RetAtsB111BillAgreeSubmit retAts = new RetAtsB111BillAgreeSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB111BillAgreeSubmitDetail detail = new RetAtsB111BillAgreeSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            XElement respinfo = getBillRespInfo(query.detail.billNo, query.detail.billNo.substring(0, 1), "1014", query.detail.actNum, query.reqHeader.srcBankCode);
//                            if (respinfo == null) {
//                                throw new Exception("获取同意清偿人信息失败");
//                            }
//                            txCode = "P1ECDS213";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt1", query.detail.billAmt);//原电票票据金额
//                            int testEnvDiffDay = getBankConfig().getValueAsInt("testEnvDiffDay", 0);
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", Format.Date8Format.format(DateHelper.addDays(new Date(), testEnvDiffDay)));//同意清偿日期 TODO
//                            xmlWriterWithoutCDATA.writeElementString("BkAmt2", query.detail.agreeAmt);//同意清偿金额
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//同意清偿备注
//                            String bkType = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", bkType);//同意清偿人信息类别
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", respinfo.getSingleText("Bk60Name7"));//同意清偿人信息名称
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//同意清偿人信息组织机构代码
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//同意清偿人信息账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", respinfo.getSingleText("BkBrchNo7"));//同意清偿人开户行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2", "");//同意清偿人开户行号2
//                            String[] ecdsInfo = query.detail.busiNo.split("_");
////                11 BkOldPlatDate  原ECDS平台日期          Char(8) F 　 　
//                            xmlWriterWithoutCDATA.writeElementString("BkOldPlatDate", ecdsInfo[0]);
////                12 BkOldSeq  原ECDS平台流水            NUMBER(20) F 　
//                            xmlWriterWithoutCDATA.writeElementString("BkOldSeq", ecdsInfo[1]);
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkAmt1", query.detail.billAmt);//原电票票据金额
//                            xmlWriterWithoutCDATA.writeElementString("Bk8Date1", Format.Date8Format.format(DateHelper.addDays(new Date(), testEnvDiffDay)));//同意清偿日期 TODO
//                            xmlWriter.writeElementCDATA("BkAmt2", query.detail.agreeAmt);//同意清偿金额
//                            xmlWriter.writeElementCDATA("BkDetail2", query.detail.memo + "_" + query.detail.reqSeqID);//同意清偿备注
//                            xmlWriter.writeElementCDATA("BkType1", bkType);//同意清偿人信息类别
//                            xmlWriter.writeElementCDATA("Bk60Name1", respinfo.getSingleText("Bk60Name7"));//同意清偿人信息名称
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//同意清偿人信息组织机构代码
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//同意清偿人信息账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", respinfo.getSingleText("BkBrchNo7"));//同意清偿人开户行号
//                            xmlWriter.writeElementCDATA("BkBrchNo2", "");//同意清偿人开户行号2
////                11 BkOldPlatDate  原ECDS平台日期          Char(8) F 　 　
//                            xmlWriter.writeElementCDATA("BkOldPlatDate", ecdsInfo[0]);
////                12 BkOldSeq  原ECDS平台流水            NUMBER(20) F 　
//                            xmlWriter.writeElementCDATA("BkOldSeq", ecdsInfo[1]);
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    //交易撤回
//    @Override
//    public RetAtsB112BillCancSubmit D_B112_BillResp_Submit(ReqB112BillCancSubmit query) throws Exception {
//        RetAtsB112BillCancSubmit retAts = new RetAtsB112BillCancSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB112BillCancSubmitDetail detail = new RetAtsB112BillCancSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            String bkType;
//                            switch (Integer.valueOf(query.detail.cancelType)) {
//                                case 1:
//                                    bkType = "0001";
//                                    break;//
//                                case 2:
//                                    bkType = "0002";
//                                    break;
//                                case 3:
//                                    bkType = "0003";
//                                    break;
//                                case 4:
//                                    bkType = "0004";
//                                    break;
//                                case 5:
//                                    bkType = "0005";
//                                    break;
//                                case 6:
//                                    bkType = "0007";
//                                    break;
//                                case 7:
//                                    bkType = "0016";
//                                    break;
//                                case 8:
//                                    bkType = "0017";
//                                    break;
//                                case 9:
//                                    bkType = "0018";
//                                    break;
//                                case 10:
//                                    bkType = "0008";
//                                    break;
//                                case 11:
//                                    bkType = "0009";
//                                    break;
//                                case 12:
//                                    bkType = "0006";
//                                    break;
//                                default:
//                                    throw new Exception("未知的撤销类型：" + query.detail.cancelType);
//                            }
//                            txCode = "P1ECDS215";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkType1", bkType);//撤销类型
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            String bkrole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkrole);//撤销申请人类别
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票回复人组织机构代码  TODO
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo1", query.detail.actNum);//撤销申请人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", getBankConfig().getMapAdvanceValue("accInfo", "key", "bankCode", query.detail.actNum));//原电票回复人开户行行号 TODO
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2", "");//原电票回复人承接行行号
//                            String[] ecdsInfo = query.detail.busiNo.split("_");
//                            xmlWriterWithoutCDATA.writeElementString("BkOldPlatDate", ecdsInfo[0]);//原ECDS平台日期
//                            xmlWriterWithoutCDATA.writeElementString("BkOldSeq", ecdsInfo[1]);//原ECDS平台流水
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkType1", bkType);//撤销类型
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkRole", bkrole);//撤销申请人类别
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票回复人组织机构代码  TODO
//                            xmlWriter.writeElementCDATA("BkAcctNo1", query.detail.actNum);//撤销申请人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", getBankConfig().getMapAdvanceValue("accInfo", "key", "bankCode", query.detail.actNum));//原电票回复人开户行行号 TODO
//                            xmlWriter.writeElementCDATA("BkBrchNo2", "");//原电票回复人承接行行号
//                            xmlWriter.writeElementCDATA("BkOldPlatDate", ecdsInfo[0]);//原ECDS平台日期
//                            xmlWriter.writeElementCDATA("BkOldSeq", ecdsInfo[1]);//原ECDS平台流水
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception ex) {
//                ex.printStackTrace();
//                detail.respCode = "-1";
//                detail.respInfo = ex.getMessage();
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//
//    @Override
//    public RetAtsB113ProtocolSubmit D_B113_ProtocolResp_Submit(ReqB113ProtocolSubmit query) throws Exception {
//        return null;
//    }
//
//    //质押解除申请
//    @Override
//    public RetAtsB119BillRelePledSubmit D_B119_BillResp_Submit(ReqB119BillRelePledSubmit query) throws Exception {
//        RetAtsB119BillRelePledSubmit retAts = new RetAtsB119BillRelePledSubmit(query.reqHeader);
//        retAts.writeBeforeDetail();
//        while (query.readRecord()) {
//            RetAtsB119BillRelePledSubmitDetail detail = new RetAtsB119BillRelePledSubmitDetail();
//            try {
//                getBnkToken();
//                if (StringHelper.hasAnyChar(bankFront.token)) {
//                    if (new File(String.format("%1$s%2$s_BnkPubKey.txt", strtmpFile, bankFront.org)).exists()) {
//                        if (!"".equals(bankFront.loginFlag) && !"false".equals(bankFront.loginFlag)) {
//                            txCode = "P1ECDS210";
//                            reqSeqID = query.reqHeader.transSeqID;
//                            XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//                            //写入报文头部信息
//                            writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//                            xmlWriterWithoutCDATA.writeStartElement("request");
//                            writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, query.detail.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriterWithoutCDATA.writeElementString("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriterWithoutCDATA.writeElementString("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出质人备注
//                            String bkRole = getBankConfig().getMapAdvanceValue("accInfo", "key", "opertorRole", query.detail.actNum);
//                            xmlWriterWithoutCDATA.writeElementString("BkRole", bkRole);//出质人类别
//                            xmlWriterWithoutCDATA.writeElementString("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出质人组织机构代码  TODO 待确认
//                            xmlWriterWithoutCDATA.writeElementString("Bk60Name1", query.detail.receName);//原电票质权人名称
//                            xmlWriterWithoutCDATA.writeElementString("BkAcctNo", query.detail.receAct);//原电票质权人账号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo1", query.detail.receBnkCode);//质权人开户行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBrchNo2", "");//质权人承接行行号
//                            xmlWriterWithoutCDATA.writeElementString("BkBatNo", query.detail.reqSeqID);//批次号
//                            xmlWriterWithoutCDATA.writeEndDocument();
//                            int n = xmlWriterWithoutCDATA.toXmlString().length();
//                            xmlLength = decimalFormat.format(n);
//
//                            XmlTextWriter xmlWriter = new XmlTextWriter();
//                            writeCommonHeader(xmlWriter);
//                            xmlWriter.writeStartElement("request");
//                            writeElecBillComEntity(xmlWriter, query.reqHeader.reqSeqID, query.reqHeader.srcBankCode, 0);
//                            xmlWriter.writeElementCDATA("BkListNo1", query.detail.billNo);//原电票电子票据号码
//                            xmlWriter.writeElementCDATA("BkDetail1", query.detail.memo + "_" + query.detail.reqSeqID);//出质人备注
//                            xmlWriter.writeElementCDATA("BkRole", bkRole);//出质人类别
//                            xmlWriter.writeElementCDATA("BkInstNo", getBankConfig().getMapAdvanceValue("accInfo", "key", "orgCode", query.detail.actNum));//原电票出质人组织机构代码  TODO 待确认
//                            xmlWriter.writeElementCDATA("Bk60Name1", query.detail.receName);//原电票质权人名称
//                            xmlWriter.writeElementCDATA("BkAcctNo", query.detail.receAct);//原电票质权人账号
//                            xmlWriter.writeElementCDATA("BkBrchNo1", query.detail.receBnkCode);//质权人开户行行号
//                            xmlWriter.writeElementCDATA("BkBrchNo2", "");//质权人承接行行号
//                            xmlWriter.writeElementCDATA("BkBatNo", query.detail.reqSeqID);//批次号
//                            xmlWriter.writeEndDocument();
//
//                            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//                            if (tmpStrRet[0].length() == 0) {
//                                StringBuilder msg = new StringBuilder();
//                                XmlTextReader tmpBkReader = getBankInfo(tmpStrRet[1], msg);
//                                if (tmpBkReader != null) {
//                                    String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                                    String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                                    String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                                    detail.respCode = "0";
//                                    detail.reqSeqID = query.detail.reqSeqID;
//                                    if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                                        String strResultCode = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_RET");
//                                        detail.respInfo = tmpBkReader.getFirstText("/Transaction/Transaction_Body/response/__ERR_MSG");
//                                        detail.transState = strResultCode;
//                                    } else {
//                                        detail.respInfo = xln_status + xln_resp_code + xln_resp_desc;
//                                        detail.transState = xln_resp_code;
//                                    }
//                                    detail.payInfoCode = detail.transState;
//                                } else {
//                                    detail.respCode = "-1";
//                                    detail.respInfo = msg.toString();
//                                }
//                            } else {
//                                detail.respCode = "-1";
//                                detail.respInfo = tmpStrRet[1];
//                            }
//                        } else {
//                            detail.respCode = "-1";
//                            detail.respInfo = "签到失败";
//                        }
//                    } else {
//                        detail.respCode = "-1";
//                        detail.respInfo = "下载银行pub密钥失败";
//                    }
//                } else {
//                    detail.respCode = "-1";
//                    detail.respInfo = "下载银行3des密钥失败";
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//                WriteBankLogLn("质押异常:" + e.getMessage());
//            }
//            retAts.writeDetail(detail);
//        }
//        retAts.writeEnd();
//        return retAts;
//    }
//
//    private XmlTextReader queryBillByP1ECDS252(String protocol, String bkInstNo, String srcBankCode) throws Exception {
//        txCode = "P1ECDS252";
//        reqSeqID = getQryTransID();
//        XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//        //写入报文头部信息
//        writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//        xmlWriterWithoutCDATA.writeStartElement("request");
//        writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, reqSeqID, srcBankCode, 0);
//        xmlWriterWithoutCDATA.writeElementString("BkFlag1", "0");//原电票协议编号
//        xmlWriterWithoutCDATA.writeElementString("BkListNo1", protocol);//原电票协议编号
//        xmlWriterWithoutCDATA.writeElementString("BkInstNo", bkInstNo);//原电票组织机构代码
//        xmlWriterWithoutCDATA.writeEndDocument();
//        int n = xmlWriterWithoutCDATA.toXmlString().length();
//        xmlLength = decimalFormat.format(n);
//
//        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
//        writeCommonHeader(xmlWriter);
//        xmlWriter.writeStartElement("request");
//        xmlWriter.writeElementCDATA("BkFlag1", "0");//原电票协议编号
//        xmlWriter.writeElementCDATA("BkListNo1", protocol);//原电票协议编号
//        xmlWriter.writeElementCDATA("BkInstNo", bkInstNo);//原电票组织机构代码
//        xmlWriter.writeEndDocument();
//        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送给银行
//        if (tmpStrRet[0].length() == 0) {
//            StringBuilder tmpSbMsg = new StringBuilder();
//            XmlTextReader tmpBkReader = null;
//            tmpBkReader = getBankInfo(tmpStrRet[1], tmpSbMsg);
//
//            if (tmpBkReader != null) {
//                String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                    return tmpBkReader;
//                } else {
//                    WriteBankLogLn("错误信息：" + xln_status + xln_resp_code + xln_resp_desc);
//                    throw new Exception(xln_status + xln_resp_code + xln_resp_desc);
//                }
//            } else {
//                WriteBankLogLn("错误信息：" + tmpSbMsg);
//                throw new Exception(tmpBkReader.toString());
//            }
//        } else {
//            WriteBankLogLn("错误信息：" + tmpStrRet[1]);
//            throw new Exception(tmpStrRet[1]);
//        }
//    }
//
//    /**
//     * 获取票据的应答者信息
//     *
//     * @param billNo
//     * @param billType
//     * @return
//     * @throws Exception
//     */
//    private XElement getBillRespInfo(String billNo, String billType, String operater, String actNum, String srcBankCode) throws Exception {
//        txCode = "P1ECDS256";
//        reqSeqID = getQryTransID();
//        if ("1".equals(billType)) {
//            billType = "AC01";
//        } else {
//            billType = "AC02";
//        }
//        XmlTextWriter xmlWriterWithoutCDATA = new XmlTextWriter();//发银行报文的XML对象
//        //写入报文头部信息
//        writeCommonHeaderWithoutCDATA(xmlWriterWithoutCDATA);
//        xmlWriterWithoutCDATA.writeStartElement("request");
//        writeElecBillComEntityWithoutCDATA(xmlWriterWithoutCDATA, reqSeqID, srcBankCode, 0);
//        xmlWriterWithoutCDATA.writeElementString("BkType1", billType);//只能填写 AC02商承
//        xmlWriterWithoutCDATA.writeElementString("Bk8Date1", "");//原电票交易日期
//        String busiType = "";
//        if ("1014".equals(operater)) {
//            busiType = "0002";
//        }
//        xmlWriterWithoutCDATA.writeElementString("BkType2", busiType);//应答类型
//        xmlWriterWithoutCDATA.writeElementString("BkOthBrchNo1", "");//承兑人
//        xmlWriterWithoutCDATA.writeElementString("BkFlag1", "");//背书转让标示
//        xmlWriterWithoutCDATA.writeElementString("BkFlag3", "");//到期期限
//        xmlWriterWithoutCDATA.writeElementString("BkFlag2", "");//出票人与承兑人是否相同
//        xmlWriterWithoutCDATA.writeElementString("BkListNo1", "");//下载任务编号
//        xmlWriterWithoutCDATA.writeElementString("BkInstNo1", "");//原申请人组织代码
//        xmlWriterWithoutCDATA.writeElementString("BkAcctNum", "1");//账号数量
//        xmlWriterWithoutCDATA.writeStartElement("BkAcctQuery_GRP");
//        xmlWriterWithoutCDATA.writeElementString("BkEcdQueryAcct", actNum);//账号
//        xmlWriterWithoutCDATA.writeEndElement();
//        xmlWriterWithoutCDATA.writeEndDocument();
//        int n = xmlWriterWithoutCDATA.toXmlString().length();
//        xmlLength = decimalFormat.format(n);
//
//        XmlTextWriter xmlWriter = new XmlTextWriter();
//        writeCommonHeader(xmlWriter);
//        xmlWriter.writeStartElement("request");
//        writeElecBillComEntity(xmlWriter, reqSeqID, srcBankCode, 0);
//        xmlWriter.writeElementCDATA("BkInstNo", "");//原电票出票人组织机构代码
//        xmlWriter.writeElementCDATA("BkType1", billType);//AC01银承
//        xmlWriter.writeElementCDATA("Bk8Date1", "");//原电票交易日期
//        xmlWriter.writeElementCDATA("BkType2", busiType);//应答类型
//        xmlWriter.writeElementCDATA("BkOthBrchNo1", "");//承兑人
//        xmlWriter.writeElementCDATA("BkFlag1", "");//背书转让标示
//        xmlWriter.writeElementCDATA("BkFlag3", "");//到期期限
//        xmlWriter.writeElementCDATA("BkFlag2", "");//出票人与承兑人是否相同
//        xmlWriter.writeElementCDATA("BkListNo1", "");//下载任务编号
//        xmlWriter.writeElementCDATA("BkInstNo1", "");//原申请人组织代码
//        xmlWriter.writeElementCDATA("BkAcctNum", "1");//账号数量
//        xmlWriter.writeStartElement("BkAcctQuery_GRP");
//        xmlWriter.writeElementCDATA("BkEcdQueryAcct", actNum);//账号数量
//        xmlWriter.writeEndElement();
//        xmlWriter.writeEndDocument();
//
//        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
//
//        if (tmpStrRet[0].length() == 0) {
//            StringBuilder tmpSbMsg = new StringBuilder();
//            XmlTextReader tmpBkReader = null;
//            tmpBkReader = getBankInfo(tmpStrRet[1], tmpSbMsg);
//
//            if (tmpBkReader != null) {
//                String xln_status = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_TX_STATUS"); // 服务状态
//                String xln_resp_code = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_CODE"); // 服务响应码
//                String xln_resp_desc = tmpBkReader.getFirstText("/Transaction/Transaction_Header/SYS_RESP_DESC"); // 服务响应描述
//                if ("00".equals(xln_status) && "000000000000".equals(xln_resp_code)) {
//                    while (tmpBkReader.read("/Transaction/Transaction_Body/response/BkDqs_GRP")) {
//                        if (billNo.equals(tmpBkReader.readedXElement.getSingleText("BkListNo1"))) {
//                            return tmpBkReader.readedXElement;
//                        }
//                    }
//                } else {
//                    WriteBankLogLn("错误信息：" + xln_status + xln_resp_code + xln_resp_desc);
//                    throw new Exception(xln_status + xln_resp_code + xln_resp_desc);
//                }
//            } else {
//                WriteBankLogLn("错误信息：" + tmpSbMsg);
//                throw new Exception(tmpBkReader.toString());
//            }
//        } else {
//            WriteBankLogLn("错误信息：" + tmpStrRet[1]);
//            throw new Exception(tmpStrRet[1]);
//        }
//        return null;
//    }
//}
